// 财务统计报表
import axios from 'axios'
const modelUrl = '/finance'
// 总资产
export interface TotalAssetsRes {
  totalAssetAmt: number
  accountBalance: number
  pendingInBillAmt: number
  pendingOutBillAmt: number
  stockAmt: number
  fixAssetAmt: number
}
export interface TotalAssetsSearch {
  TotalTime: string[]
  startDate: string
  endDate: string
}
export function getTotalAssets(data?: TotalAssetsSearch) {
  return axios.post<TotalAssetsRes>(modelUrl + '/financeAssetStat', data)
}

// 经营情况
export interface BusinessSituationRes {
  reportMonth: string
  accountBalance: string
  pendingInBillAmt: string
  pendingOutBillAmt: string
  stockAmt: string
  totalAmt: string
  index?: number // 导出的序号
}
export interface BusinessSituationSearch {
  TotalTime: string[]
  startDate: string
  endDate: string
}
export function getBusinessSituation(data?: BusinessSituationSearch) {
  return axios.post<{ list: BusinessSituationRes[] }>(modelUrl + '/financeBusinessStat', data)
}

// 销售情况
export interface SalesStatusRes {
  currentPage?: number
  pageSize?: number
  totalPage?: number
  totalCount?: number
  list: SalesStatusResItem[]
  titleList: string[]
}
export interface SalesStatusResItem {
  customerId: string
  customerName: string
  totalAmt?: any
  itemDetailList: number[] | string[]
  index?: number // 导出的序号
}
export interface SalesStatusSearch {
  TotalTime: string[]
  startDate: string
  endDate: string
}
export function getSalesStatus(data?: SalesStatusSearch) {
  return axios.post<SalesStatusRes>(modelUrl + '/financeSaleStat', data)
}

// 材料采购
export interface MaterialPurchaseRes {
  currentPage?: number
  pageSize?: number
  totalPage?: number
  totalCount?: number
  list: MaterialPurchaseResItem[]
  titleList: string[]
}
export interface MaterialPurchaseResItem {
  supplierId: string
  supplierName: string
  itemList: MaterialPurchaseItemList[]
}

export interface MaterialPurchaseItemList {
  itemName: string
  totalAmt: number
  itemDetailList: number[]
}

export interface MPItemHandleAfterType {
  supplierId: string
  supplierName: string
  itemName: string
  totalAmt: number | string
  itemDetailList: (number | string)[]
  span?: number
  index?: number // 导出的序号
}

export interface MaterialPurchaseSearch {
  TotalTime: string[]
  startDate: string
  endDate: string
}
export function getMaterialPurchase(data?: MaterialPurchaseSearch) {
  return axios.post<MaterialPurchaseRes>(modelUrl + '/financePurchaseStat', data)
}

// 收支情况
export interface IncomeExpenditureRes {
  seq: string
  itemName: string
  itemContent: string
  amt: number
  remark?: any
  childrenList?: IncomeExpenditureRes[]
  index?: number // 导出的序号
}
export interface IncomeExpenditureSearch {
  TotalTime: string[]
  startDate: string
  endDate: string
}
export function getIncomeExpenditure(data?: IncomeExpenditureSearch) {
  return axios.post<{ list: IncomeExpenditureRes[] }>(modelUrl + '/financeIncomeExpendStat', data)
}
